package com.zfx.aop;

import com.zfx.aop.CgLibUtils;
import com.zfx.service.MyAopService;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
// Spring AOP的实现实际上是 通过beanPostProcessor (bean的后置处理器), 通过 postProcessAfterInitialization 方法来实现的
public class CustomerAopBeanPostProcessor implements BeanPostProcessor {
	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		if (bean instanceof MyAopService){
			bean = CgLibUtils.cgLib();
		}
		return bean;
	}
}
